/**
 * @file main.cpp
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @brief 给定一棵无重边无自环的树，给定树中一条边，求包含该边的最小的生成树
 *
 * 可以如此考虑：
 *
 * 设给定的边为 (x, y)，先使用 Kruskal 算法找到 MST ，再去掉连接节点 x 和 y
 * 的路径上最重的一条边， 最后把 (x, y) 那条边加上。
 *
 * 找到最重的边可以先找树根到LCA(x, y)的最重的边，再找LCA(x,y)到 x 和 y
 * 中最重的边，取三者最大值。
 *
 * 时间复杂度：O(M*log(N))
 *
 * @version 0.1
 * @date 2022-04-29
 *
 * @copyright Copyright (c) 2022
 *
 */

#include <bits/stdc++.h>
using namespace std;
const int N = 210000;
const int L = 17;
int n, m;
vector<pair<int, int>> g[N];
vector<tuple<int, int, int>> edges, edges2, mst;
int w[N];
long long cost;
int timer;
int up[N][L + 1];
int bedge[N][L + 1];
int tin[N], tout[N], dep[N];

void dfs(int v, int p = 1, int pcost = 0) {
  tin[v] = timer++;
  up[v][0] = p;
  bedge[v][0] = pcost;
  for (int i = 1; i <= L; ++i) {
    up[v][i] = up[up[v][i - 1]][i - 1];
    bedge[v][i] = max(bedge[v][i - 1], bedge[up[v][i - 1]][i - 1]);
  }
  for (auto [to, cost] : g[v]) {
    if (to == p) continue;
    dep[to] = dep[v] + 1;
    dfs(to, v, cost);
  }
  tout[v] = timer++;
}

int get(int x) {
  if (x == w[x]) return x;
  return w[x] = get(w[x]);
}

bool upper(int a, int b) {
  return (tin[a] <= tin[b] && tout[a] >= tout[b]);  // 去掉等号是不是也可以
}

int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = L; i >= 0; --i) {
    if (!upper(up[a][i], b)) a = up[a][i];
  }
  return up[a][0];
}

void merge(int a, int b) {
  if (rand() % 2) swap(a, b);
  a = get(a), b = get(b);
  w[a] = b;
}

int get_best(int v, int span) {
  int ret = 0;
  for (int i = L; i >= 0; --i) {
    if (span & (1 << i)) {
      ret = max(ret, bedge[v][i]);
      v = up[v][i];
    }
  }
  return ret;
}

int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    edges.push_back({c, a, b});
    edges2.push_back({c, a, b});
  }
  sort(edges.begin(), edges.end());
  for (int i = 1; i <= n; ++i) w[i] = i;
  for (auto [c, a, b] : edges) {
    int ta = get(a), tb = get(b);
    if (ta == tb) continue;
    merge(ta, tb);
    mst.push_back({c, a, b});
    cost += c;
  }
  for (auto [cost, v1, v2] : mst) {
    g[v1].push_back({v2, cost});
    g[v2].push_back({v1, cost});
  }
  dfs(1);
  for (auto [c, v1, v2] : edges2) {
    int l = lca(v1, v2);
    int bst = 0;
    bst = max(
        {bst, get_best(v1, dep[v1] - dep[l]), get_best(v2, dep[v2] - dep[l])});
    cout << cost + c - bst << '\n';
  }
}
